from django.contrib import admin
from .models import *


# Register your models here.

@admin.register(Products)
class ProductsAdmin(admin.ModelAdmin):
    list_display = ['id', 'name']
@admin.register(Versions)
class VersionsAdmin(admin.ModelAdmin):
    list_display = ['id', 'name']

@admin.register(Tags)
class TagsAdmin(admin.ModelAdmin):
    list_display = ['id', 'name']


@admin.register(Document)
class DocumentAdmin(admin.ModelAdmin):
    list_display = ['title', 'product', 'show_tags']

    '''展示tags'''
    def show_tags(self,obj):
        tags = []
        for tag in obj.tags.all():
            tags.append(tag.name)
        return tags
    show_tags.short_description = '标签'  # 设置表头

@admin.register(FAQ)
class FAQAdmin(admin.ModelAdmin):
    list_display = ['id', 'product']

@admin.register(Tools)
class ToolsAdmin(admin.ModelAdmin):
    list_display = ['id', 'title']
